package com.zqh.web.exception;


import com.zqh.web.common.result.BaseResponse;
import com.zqh.web.common.ErrorCode;
import com.zqh.web.common.result.Result;
//import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
@Hidden
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public BaseResponse<?> businessExceptionHandler(BusinessException e) {
//        log.error("BusinessException", e);
        return Result.error(e.getCode(), e.getMessage());
    }

//    @ExceptionHandler(RuntimeException.class)
//    public BaseResponse<?> runtimeExceptionHandler(RuntimeException e) {
////        log.error("RuntimeException", e);
//        return Result.error(ErrorCode.SYSTEM_ERROR, "系统错误");
//    }

}
